function patient = create_model_folders_toolbox(patient)
    % Pre-ampble for 5D Model toolbox;
    %|  Creates folders, and loads static image and static mask (lung and
    %|  body contours)
    %------------------------------------------------------------------------
    %|      Dependancies;                                                     |
    %|                                                          |
    %------------------------------------------------------------------------
    %   This file is part of the
    %   5D-Novel4DCT Toolbox  ("Novel4DCT-Toolbox")
    %   DH Thomas, Ph.D
    %   University of California, Los Angeles
    %   Contact: mailto:dhthomas@mednet.ucla.edu
    %------------------------------------------------------------------------
    % $Author: DHThomas $	$Date: 2014/04/01 10:23:59 $	$Revision: 0.1 $




if exist(patient.folder, 'dir')<7;
    mkdir(patient.folder);
end

patient.model_folder = [patient.folder sprintf('/model_params_5d_%dscans',patient.scans)];  %define and create patient model folder;

if exist(patient.model_folder, 'dir')<7;
    mkdir(patient.model_folder);
end

% Load the static reference image and lung & body masks;
display(sprintf('Reading STATIC_MASK'))
if exist('metaImageRead')<1;
    display('Please add subfolder "functions" to path');
end
patient.static_mask=logical(single(metaImageRead([patient.folder_static '/' patient.static_mask_name])));

display(sprintf('Reading BODY_MASK'))
patient.body_mask=logical(single(metaImageRead([patient.folder_static '/' patient.static_body_name])));

display(sprintf('Reading STATIC IMAGE'))
patient.static=single(metaImageRead([patient.folder_static '/' patient.static_image_name]));

patient.dim=size(patient.static); %size of image
